package com.qiaofang.applet.service.property.service.impl;

import com.qiaofang.applet.common.base.MongoBaseService;
import com.qiaofang.applet.common.context.QfContextHolder;
import com.qiaofang.applet.service.property.domain.PropertyVideo;
import com.qiaofang.applet.service.property.repository.PropertyVideoRepository;
import com.qiaofang.applet.service.property.service.PropertyVideoService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

@Slf4j
@Service
public class PropertyVideoServiceImpl extends MongoBaseService<PropertyVideo, String> implements PropertyVideoService {

    private final PropertyVideoRepository repository;

    public PropertyVideoServiceImpl(PropertyVideoRepository repository) {
        super(repository);
        this.repository = repository;
    }

    @Override
    public PropertyVideo findByVideoUuidAndCompanyUuid(String videoUuid, String companyUuid) {
        return repository.findByVideoUuidAndCompanyUuid(videoUuid, companyUuid);
    }

    @Override
    public PropertyVideo findByPropertyUuidAndCityCode(String propertyUuid, String cityCode) {
        return repository.findFirstByPropertyUuidAndCityCodeAndCorporationCode(propertyUuid, cityCode, QfContextHolder.getContext().getCorporationCode());
    }
}
